import request from "@/utils/request";

export const add = (params) => {
  const {
    date,
    code,
    type,
    start,
    startPinyin,
    startTime,
    end,
    endPinyin,
    endTime,
  } = params;
  return request.post("/daily-train/admin/train/add", {
    date,
    code,
    type,
    start,
    startPinyin,
    startTime,
    end,
    endPinyin,
    endTime,
  });
};

export const getPage = (pageNo, pageSize, searchParams) => {
  const { date, code } = searchParams;
  return request.post("/daily-train/admin/train/page", {
    pageNo,
    pageSize,
    date,
    code,
  });
};

export const remove = (id) => {
  return request.delete(`/daily-train/admin/train/remove/${id}`);
};

export const edit = (params) => {
  const {
    id,
    date,
    code,
    type,
    start,
    startPinyin,
    startTime,
    end,
    endPinyin,
    endTime,
  } = params;
  return request.post("/daily-train/admin/train/edit", {
    id,
    date,
    code,
    type,
    start,
    startPinyin,
    startTime,
    end,
    endPinyin,
    endTime,
  });
};

export const createDailyTrain = (date) => {
  return request.post(`/daily-train/admin/train/generate-train/${date}`);
};